<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

<script type="text/javascript">

    function Person (name, age, gender) {
        this.name = name
        this.age = age
        this.gender = gender
    }
    console.log(new Person('name', 10, '男'))
    Person.prototype = {
        constructor: Person,
        sayName: function () {
            console.log(this.name)
        }
    }
    var wukong = new Person('悟空', '500', '男')
    var bajie = new Person('八戒', '500', '不祥')
    wukong.sayName()    // 悟空
    bajie.sayName()     // 八戒
    wukong.name = '大圣'  //修改的是实例对象的属性
    wukong.sayName()    // 大圣
    bajie.sayName()     // 八戒

</script>

</body>
</html>
